
package hk.ces.oxfam.patch.transaction;

import hk.ces.oxfam.patch.TransactionPatch;
import hk.ces.oxfam.patch.TransactionStrategy;
import hk.ces.oxfam.patch.TransactionStrategyType;
import hk.ces.oxfam.patch.db.result.ExcuteResult;
import hk.ces.oxfam.patch.db.sql.PreparedSQL;
import hk.ces.oxfam.patch.db.sql.SQLUtil;
import java.sql.Connection;
import java.sql.SQLException;

/**
 *
 * @author ReutyCheng
 */
@TransactionStrategy(TransactionStrategyType.ROLLBACK)
public class PersonDisabledUpdatePatch implements TransactionPatch
{
  public void run(Connection connection) throws SQLException
  {
    this.updatedDisabled(connection);
  }

  private void updatedDisabled(Connection connection) throws SQLException
  {
    String sql = "update personinfo set disabled = ? where disabled is null";
    Object[] params = new Object[]{false};
    ExcuteResult resultCount = SQLUtil.execute(connection, new PreparedSQL(sql, params));
    System.out.println(resultCount.getExcuteStatus() + "|" + resultCount.getResultCount());
  }
}
